package com.qyhl.webtv.module_user.shop.code;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.user.ShoppingOrderBean;
import com.qyhl.webtv.module_user.common.UserUrl;

public class ShopCodeModel implements ShopCodeContract.ShopCodeModel {
    private ShopCodePresenter mPresenter;

    public ShopCodeModel(ShopCodePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(String id) {
        EasyHttp.get(UserUrl.GET_SHOP_ORDER_Detail)
                .params("orderId", id)
                .execute(new SimpleCallBack<ShoppingOrderBean>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容！");
                        } else {
                            mPresenter.setError("请求出错，请重新获取！");
                        }
                    }

                    @Override
                    public void onSuccess(ShoppingOrderBean bean) {
                          mPresenter.setDetail(bean);
                    }
                });
    }
}
